import { createRouter, createWebHashHistory } from "vue-router";

export const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: "/",
      redirect: "/layout",
    },
    {
      path: "/login",
      name: 'login',
      component: () => import("../pages/Login/index.vue"),
    },
    {
      path: "/layout",
      component: () => import("../components/Layout.vue"),
      name: "layout",
      meta: {
        isCrumb: false,
      },
      children: [
        {
          path: "/layout",
          redirect: "/cargoList",
        },
        {
          path: "/cargoList",
          component: () => import("../pages/CargoList/index.vue"),
          name: "cargoList",
          meta: {
            isCrumb: true,
            path: "/cargoList",
            crumb: "商品列表",
          },
          children: [],
        },
        {
          path: "/cargoList/cargoAdd",
          component: () => import("../pages/CargoList/CargoAdd/index.vue"),
          name: "cargoAdd",
          meta: {
            isCrumb: true,
            path: "/cargoAdd",
            crumb: "新增商品",
          },
        },
        {
          path: "/businessList",
          component: () => import("../pages/BusinessList/index.vue"),
          name: "businessList",
          meta: {
            isCrumb: true,
            path: "/businessList",
            crumb: "商家列表",
          },
        },
        {
          path: "/orderList",
          component: () => import("../pages/OrderList/index.vue"),
          name: "orderList",
          meta: {
            isCrumb: true,
            path: "/orderList",
            crumb: "订单列表",
          },
        },
        {
          path: "/tradeList",
          component: () => import("../pages/TradeList/index.vue"),
          name: "tradeList",
          meta: {
            isCrumb: true,
            path: "/tradeList",
            crumb: "交易统计",
          },
        },
      ],
    },
  ],
});
